﻿using System.Web;
using System.Web.UI;

/// <summary>
/// Summary description for UiUtillities
/// </summary>
public static class UiUtillity
{
    // if the control is a postback control 
    public static void ScrollIntoView(Control controlToScroll)
    {
        Page page = HttpContext.Current.Handler as Page;
        page.ClientScript.RegisterStartupScript(typeof(UiUtillity), "ScrollIntoView", "<script> document.getElementById('" + controlToScroll.ClientID + "').scrollIntoView();</script>");
    }

    // if the control is an asyncronous postback control 
    public static void ScrollIntoViewForAsync(Control controlToScroll)
    {
        Page page = HttpContext.Current.Handler as Page;
        ScriptManager.RegisterClientScriptBlock(page, typeof(UiUtillity), "ScrollIntoViewForAsync", "document.getElementById('" + controlToScroll.ClientID + "').scrollIntoView();", true);
    }
}
